import request from '@/api/axios.js';
import request2 from '@/api/axios2.js';

const login = (data)=>{
    return request2({
        url: '/user/login',
        method: 'post',
        data
    })
}

const getUserInfo = ()=>{
    return request2({
        url: '/user/getUser',
        method: 'post'
    })
}

const loginOut = ()=>{
    return request2({
        url: '/user/logout',
        method: 'post'
    })
}

const generateRoutes = ()=>{
    return request2({
        url: '/user/getRouterByUser',
        method: 'post'
    })
}

const passWordChange = (data)=>{
    return request({
        url: '/admin/passWordChange',
        method: 'post',
        data
    })
}
const getUserList = (params) =>{
    return request2({
        url: '/user/pageList',
        method: 'post',
        params
    })
}
const delUser = (data) =>{
    return request2({
        url:'/user/delUser',
        method:'delete',
        data
    })
}
const queryAllroles = (params) => {
    return request2({
        url:'/role/getAll',
        method:'get',
        params
    })
}
//添加用户
const addUser = (data)=>{
    return request2({
        url: '/user/add',
        method: 'post',
        data
    })
}

//修改用户
const editUser = (data)=>{
    return request2({
        url: '/user/edit',
        method: 'post',
        data
    })
}

//获取所有角色信息
const getAllRoles=()=>{
    return request2({
        url:'/role/getAll',
        method:'get'
    })
}

export {
    login,
    getUserInfo,
    loginOut,
    generateRoutes,
    passWordChange,
    getUserList,
    delUser,
    queryAllroles,
    addUser,
    editUser,
    getAllRoles
}